DialogBoxes using INC files

I am trying to use a dictionary include file that I have created in order to display a GUI using a selected language. The Language has been set in the registry as either french or english.

I have an include file called dictionary.inc where I attempt to create radiobuttons, comboboxes etc...

From a dxl file where I have created a dialog box I attempt to create my radiobuttons and comboboxes using this include file. However, after dynamically supplying the values from the dictionary (which is a TSV file with all values) I obtain mixed up values.

main DXL
____________________________________________________________________________________________

DB db = centered SCRIPT_NAME " v" SCRIPT_VERSION
DBE dbe_combo4
createLanguageComboBox(db, dbe_combo4, TOOL_TYPE, RADIO_BUTTON)

createLanguageRadioButton(db, dbe_baseline_type_radiobutton, TOOL_TYPE, RADIO_BUTTON)
show db
dictionary.inc
________________________________________________

void createLanguageComboBox(DB &db, DBE &comboBoxDBE, string tool_type_name, string dbe_name) {

string combo_definitioncount = {"choice1", "choice2", "choice3"}

comboBoxDBE = choice(db, null, combo_definition, 0)

}

void createLanguageRadioButton(DB &db, DBE &radioButtonDBE, string tool_type_name, string dbe_name) {

string combo_definition_radiocount = {"button1", "button2"}

radioButtonDBE = radioBox(db, "text", combo_definition_radio, 0)
}

It seems that the &db context gets mixed up when attempting to send it as parameters to the dictionary functions from my main.dxl.

I realize that this may not be a very clear definition of my problem however any ideas would be greatly appreciated.
Just to recap: My displayed GUI does not contain the correct elements when supplying DB from my main.dxl script
PatrickGuay - Thu Dec 15 09:33:58 EST 2011

Re: DialogBoxes using INC files
PatrickGuay - Thu Dec 15 14:44:32 EST 2011

I have figured out why I am getting an error. Thanks to a previous post https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14301349&#14301349

It seems that it is not possible to show a dialogBox that has methods that return stringhttp://] arrays. Maybe it is not possible to stack more than 1 array from any given method call. In order to get around this I will grab the values in the dictionary and then populate my string array[ in the same method that created the original DB.

DB db = create "dialog"

Skip dictionary_values_skip = createString()
int count = populate_and_count(dictionary_values_skip, TOOL_TYPE, RADIO_BUTTON)
string combo_definition_radiocount
fill_array_with_radio_items(dictionary_values_skip, combo_definition_radio)
dbe_baseline_type_radiobutton = radioBox(db, "", combo_definition_radio, 0)

However, I would have prefered to encapsulate everything in a helper function. DXL has decided otherwise.

Re: DialogBoxes using INC files
Mathias Mamsch - Thu Dec 15 18:48:28 EST 2011

PatrickGuay - Thu Dec 15 14:44:32 EST 2011
I have figured out why I am getting an error. Thanks to a previous post https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14301349&#14301349

It seems that it is not possible to show a dialogBox that has methods that return stringhttp://] arrays. Maybe it is not possible to stack more than 1 array from any given method call. In order to get around this I will grab the values in the dictionary and then populate my string array[ in the same method that created the original DB.

DB db = create "dialog"

Skip dictionary_values_skip = createString()
int count = populate_and_count(dictionary_values_skip, TOOL_TYPE, RADIO_BUTTON)
string combo_definition_radiocount
fill_array_with_radio_items(dictionary_values_skip, combo_definition_radio)
dbe_baseline_type_radiobutton = radioBox(db, "", combo_definition_radio, 0)

However, I would have prefered to encapsulate everything in a helper function. DXL has decided otherwise.

We have a more actual (lengthy) discussion which illuminates the reason for your problem and some solutions somewhere else:

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14472558#14472558
https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14472624&#14472624

There is some lengthy reading about dealing with arrays in DXL but the main cause of your problems is the nature of arrays. When you declare a one dimensional array inside a function, then this array will live inside the function, afterwards it will be flagged for destruction. Unfortunately radioBox and checkBox will not make a copy of your array, but just keep a reference to it. The array must be alive until you call realize or show.

If you do it like in your code, you will pass the array to radiobox inside a function but after the function ends the array will not be alive anymore. So what can you do? Well the approach you choose is one way to handle this. You can still keep a function, but you need to move the array declaration somewhere on the global level to make sure its lifetime will be long enough until realize/show.

However I would suggest you take a look in the native DOORS multi language facilities (provided you use DOORS 9.1+). See for example this post:

https://www.ibm.com/developerworks/forums/click.jspa?searchID=-1&messageID=14578658

Maybe that helps, regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS